package com.jgzx.redis.bill;

import com.jgzx.constant.inventory.InStockBillTypeEnum;
import com.jgzx.constant.inventory.OutStockBillTypeEnum;

/**
 * @author jackesy
 * @className: BillCodeEnum
 * @description: 单据编号枚举类
 * @create 2021/3/21 22:18
 **/
public enum BillCodeEnum {

    XSDD("XSDD", "销售订单"),
    CGDD("CGDD", "采购订单"),
    XSTH("XSTH", "销售退货单"),
    CGRK("CGRK", "采购入库单"),
    QTRK("QTRK", "其他入库单"),
    QCRK("QCRK", "期初入库单"),
    XSCK("XSCK", "销售出库单"),
    CGTH("CGTH", "采购退货单"),
    QTCK("QTCK", "其他出库单"),
    QCCK("QCCK", "期初出库单"),
    ZZDD("ZZDD", "组装单"),
    CFDD("CFDD", "拆分单"),
    BSDD("BSDD", "报损单"),
    BYDD("BYDD", "报溢单"),
    YSDD("YSDD", "应收单"),
    YFDD("YFDD", "应付单"),
    SKDD("SKDD", "收款单"),
    FKDD("FKDD", "付款单"),
    SCPC("SCPC", "生产排产"),
    GXBG("GXBG", "工序报工"),
    PDDD("PDDD", "盘点单"),
    BZBM("BZBM", "标准BOM单"),
    DDBM("DDBM", "订单BOM单"),
    CLCK("CLCK", "材料出库"),
    CLTK("CLTK", "材料退库"),
    CPRK("CPRK", "产成品入库"),
    CPTK("CPTK", "产成品退库"),
    DBDD("DBDD", "调拨单"),
    DBRK("DBRK", "调拨入库"),
    DBCK("DBCK", "调拨出库"),
    ZZRK("ZZRK", "组装入库"),
    ZZCK("ZZCK", "组装出库"),
    CFRK("CFRK", "拆分入库"),
    CFCK("CFCK", "拆分出库"),
    DZDD("DZDD", "对账单"),
    BLQD("BLQD", "备料清单"),
    ;


    final String value;
    final String name;

    BillCodeEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public String getValue() {
        return this.value;
    }

    public String getName() {
        return this.name;
    }

    /**
     * 返回对应入库单据类型的单据号枚举
     * @param billType 入库单据类型
     * @return BillCodeEnum
     */
    public static BillCodeEnum getEnumByInStockBillType(String billType) {
        if (InStockBillTypeEnum.PRODUCTION_IN_STOCK.value().equals(billType)) {
            return CGRK;
        } else if (InStockBillTypeEnum.TRANSFER_IN_STOCK.value().equals(billType)) {
            return DBRK;
        } else if (InStockBillTypeEnum.SALE_IN_STOCK.value().equals(billType)) {
            return XSTH;
        } else if (InStockBillTypeEnum.OVERFLOW_IN_STOCK.value().equals(billType)) {
            return BYDD;
        } else if (InStockBillTypeEnum.REQUISITION_IN_STOCK.value().equals(billType)) {
            return CLTK;
        } else if (InStockBillTypeEnum.PRODUCT_IN_STOCK.value().equals(billType)) {
            return CPRK;
        } else if (InStockBillTypeEnum.OTHER_IN_STOCK.value().equals(billType)) {
            return QTRK;
        } else if (InStockBillTypeEnum.ASSEMBLE_IN_STOCK.value().equals(billType)) {
            return ZZRK;
        } else if (InStockBillTypeEnum.SPLIT_IN_STOCK.value().equals(billType)) {
            return CFRK;
        } else if (InStockBillTypeEnum.PERIOD_IN_STOCK.value().equals(billType)) {
            return QCRK;
        } else {
            return QTRK;
        }
    }
    /**
     * 返回对应入库单据类型的单据号枚举
     * @param billType 出库单据类型
     * @return BillCodeEnum
     */
    public static BillCodeEnum getEnumByOutStockBillType(String billType) {
        if (OutStockBillTypeEnum.SALE_OUT_STOCK.value().equals(billType)) {
            return XSCK;
        } else if (OutStockBillTypeEnum.TRANSFER_OUT_STOCK.value().equals(billType)) {
            return DBCK;
        } else if (OutStockBillTypeEnum.PURCHASE_OUT_STOCK.value().equals(billType)) {
            return CGTH;
        } else if (OutStockBillTypeEnum.LOSS_OUT_STOCK.value().equals(billType)) {
            return BSDD;
        } else if (OutStockBillTypeEnum.REQUISITION_OUT_STOCK.value().equals(billType)) {
            return CLCK;
        } else if (OutStockBillTypeEnum.PRODUCT_OUT_STOCK.value().equals(billType)) {
            return CPTK;
        } else if (OutStockBillTypeEnum.OTHER_OUT_STOCK.value().equals(billType)) {
            return QTCK;
        } else if (OutStockBillTypeEnum.ASSEMBLE_OUT_STOCK.value().equals(billType)) {
            return ZZCK;
        } else if (OutStockBillTypeEnum.SPLIT_OUT_STOCK.value().equals(billType)) {
            return CFCK;
        } else if (OutStockBillTypeEnum.PERIOD_OUT_STOCK.value().equals(billType)) {
            return QCCK;
        } else {
            return QTCK;
        }
    }
}
